<!--
 * @Author: huangtianyang 916072572@qq.com
 * @Date: 2023-05-08 16:55:29
 * @LastEditors: huangtianyang
 * @LastEditTime: 2023-05-18 14:50:22
 * @FilePath: \cxl-h5\src\pages\vehicleCondition\queryRecord\CountTime.vue
-->
<template>
    <section v-if="visible">等待付款：{{ time }}</section>
</template>
<script setup lang="ts">
import { PaySetInterval, timeToTimestamp } from '@/utils'
import { watchEffect } from 'vue'
import { ref } from 'vue'

const props = defineProps(['createTime', 'expireTime'])
const time = ref('00 : 00')
const visible = ref(true)
const emits = defineEmits(['update'])

watchEffect(() => {
    new PaySetInterval(timeToTimestamp(props.expireTime), timeToTimestamp(props.createTime)).start(
        val => {
            time.value = val
        },
        () => {
            visible.value = false
            emits('update')
        }
    )
})
</script>
